package view.dialogs;

import java.util.ArrayList;

import javax.swing.JPanel;
import javax.swing.JRadioButton;

import view.listeners.CancelListener;
import view.listeners.ChooseOptionListener;
import view.views.dialogButtonViews.ConfirmButtonPanel;
import view.views.dialogContentViews.ChooseOptionContentPanel;
import controller.DialogDisposer;

/**
 * @author Alexander Müller
 * 
 */
public class ChooseOptionDialog extends Dialog {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private ArrayList<JRadioButton> buttons = new ArrayList<JRadioButton>();
	private Thread t;

	public ChooseOptionDialog(String title) {
		super(title);

	}

	@Override
	protected JPanel addContent() {
		ChooseOptionContentPanel panel = new ChooseOptionContentPanel();
		buttons = panel.getButtonList();
		return panel;
	}

	@Override
	protected JPanel addButtons() {
		ConfirmButtonPanel buttonPanel = new ConfirmButtonPanel();

		buttonPanel.getCloseButton()
				.addActionListener(new CancelListener(this));
		buttonPanel.getOKButton().addActionListener(
				new ChooseOptionListener(this, buttons));


		return buttonPanel;
	}

	public void closeDialog() {
		t = new Thread(new DialogDisposer(ChooseOptionDialog.this));
		t.start();
	}

}
